import KoaRouter from 'koa-router'
import Mock from 'mockjs'

/**
 * 当前天气
 */
export interface IWeatherCurrent {
  weather: number
  temperature: number
  wind: number
  humidity: number
}

/**
 * 天气数据
 */
export interface IWeather {
  data?: {
    current?: IWeatherCurrent
  }
}

const router = new KoaRouter()

/**
 * @api {get} /weather 获取当前天气情况
 * @apiName getWeather
 * @apiGroup Weather
 * @apiDescription 获取当前天气情况
 *
 * @apiSuccessExample {json} 获取成功
 *   HTTP/1.1 200 OK
 *   {
 *     "data": {
 *       "current": {
 *         "weather": 1,
 *         "temperature": 30
 *         "wind": 2,
 *         "humidity": 20
 *       },
 *     }
 *   }
 *
 * @apiSuccess {Object} data 天气数据
 * @apiSuccess {Object} data.current 当前天气数据
 * @apiSuccess {Number} data.current.weather 天气类别
 * @apiSuccess {Number} data.current.temperature 气温
 * @apiSuccess {Number} data.current.wind 风力
 * @apiSuccess {Number} data.current.humidity 湿度
 */
router.get('getWeather', '/', ctx => {
  ctx.body = Mock.mock({
    data: {
      current: {
        'weather|1-10': 1,
        'temperature|-50-50.2': 1,
        'wind|0-10': 1,
        'humidity|0-100.2': 1,
      },
    },
  })
})

export default router.routes()
